<!--
 * @Author: Dorange.Wang
 * @Date: 2021-04-07 16:19:40
 * @LastEditors: your name
 * @LastEditTime: 2021-04-09 08:34:31
 * @Description: file content
-->
<template>
  <el-dialog
    :visible="showVisible"
    center
    :show-close="false"
    width="600px"
  >
    <div class="b g3 f16 tl" slot="title">
      <div class="ks-row-between pl15 pr15">
        <span>{{$t('sys.sort')}}</span>
        <span
          class="el-icon-close g9 f26 poi"
          @click="showVisible = false"
        ></span>
      </div>
    </div>

    <el-form
      class="pl30 pr30"
      :model="formData"
      ref="form"
      label-width="180px"
      label-position="right"
    >
      <el-form-item
        label="序号"
        :rules="[
          { required: true, message: $t('sys.serial_number_not_null'), trigger: 'change' },
        ]"
      >
        <el-input-number
          v-model="formData.serialNum"
          :min="0"
          :max="999999999"
          style="width: 200px"
        ></el-input-number>
      </el-form-item>

    </el-form>

    <div slot="footer" class="tr">
      <el-button @click="showVisible = false">{{$t('sys.cancel')}}</el-button>
      <el-button type="primary" @click="submit">{{$t('sys.confirm')}}</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { putHmuserSort } from '@/apis/paas/HmUserController.js'

export default {
  props: {
    treeData: {
      type: Array,
      default: () => []
    }
  },

  data () {
    return {
      showVisible: false,
      formData: {}
    }
  },

  methods: {
    editForm (record) {
      this.showVisible = true
      this.formData = { ...record }
      this.$nextTick(() => {
        this.$refs.form.clearValidate()
      })
    },

    async submit () {
      try {
        await this.$refs.form.validate()
        const { id, orgId, serialNum } = this.formData
        const params = { id, orgId, serialNum }
        const request = putHmuserSort
        request(params).then(res => {
          this.showVisible = false
          this.$emit('ok')
        })
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
